<include file="Common:header" />

	<body>
		<include file="Common:nav" />

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<include file="Common:mune" />

				<div class="main-content">
					

					<div class="page-content">
						<div class="page-header">
							<h1>
								{$title}
								
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">							
								<!-- PAGE CONTENT BEGINS -->							
								<table class="table table-bordered">
									<tr>
										<th>#</th>
										<th>用户名</th>
										<th>状态</th>
										<th>登陆时间</th>
										<th>登陆IP</th>
										<th>操作</th>
									</tr>
									<foreach name="list" item="v">
									<tr>
										<td>{$v.id}</td>
										<td>{$v.username}</td>
										<td>{$v['status'] ? '激活' : '冻结'}</td>
										<td>{$v.logintime|date="Y-m-d H:i:s",###}</td>
										<td>{$v.loginip}</td>
										<td>
											<button class="btn btn-xs btn-info clickinfo" data-id="{$v.id}" data-username="{$v.username}" data-status="{$v.status}" data-toggle="modal" data-target="#myModal">
												<i class="icon-edit bigger-120"></i>
											</button>
											<button class="btn btn-xs btn-danger clickdelete" data-id="{$v.id}">
												<i class="icon-trash bigger-120"></i>
											</button>
										</td>
									</tr>
									</foreach>
									<tr>
										<td colspan="6" align="center">
											{$show}
										</td>
									</tr>
								</table>


							<div class="space-24"></div>

							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->
				
			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
				  <div class="modal-dialog" role="document">
				    <div class="modal-content">
				      <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				        <h4 class="modal-title" id="myModalLabel">编辑</h4>
				      </div>
				      <form  method="post" action="{:U('userEdit')}">
				      <div class="modal-body">
				        	<table class="table table-bordered">
					   <tr>
					   	<td>用户名:</td>
					   	<td>
					   		<div class="form-group">
										<input type="hidden" name="id" value="">
										<div class="col-sm-9">
											<input type="text" id="form-field-1" placeholder="Username" class="col-xs-10 col-sm-5" name="username" />
										</div>
									</div>
					   	</td>
					   </tr>
					   <tr>
					   	<td>密码:</td>
					   	<td>
					   		<div class="form-group">									
										<div class="col-sm-9">
											<input type="password" id="form-field-2" placeholder="Password" class="col-xs-10 col-sm-5" name="pwd" />											
										</div>
									</div>
					   	</td>
					   </tr>
					  <tr>
					  	<td>是否激活</td>
					  	<td>
					  		<div class="form-group">
										
								<div class="col-sm-9">
									<label>
									<input name="switch-field-1" class="ace ace-switch ace-switch-5" type="checkbox" >
									<span class="lbl"></span>
									</label>											
								</div>
							</div>
					  	</td>
					  </tr>

					</table>
				      </div>
				      <div class="modal-footer">
				        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				        <button type="submit" class="btn btn-primary">保存</button>
				      </div>
				    </div>
				    </form>
				  </div>
			</div>



	<include file="Common:footer" />
	<script type="text/javascript">
		var url = "{:U('userDelete')}";
	$(".clickinfo").click(function(event) {
		username = $(this).data('username');
		id = $(this).data('id');
		status = $(this).data('status');
		$("input[name='username']").val(username);
		$("input[name='id']").val(id);
		if (status != 0) {
			$("input[name='switch-field-1']").attr('checked',true);
		}

	});

	$(".clickdelete").click(function(event) {
		id = $(this).data('id');
		
		$.ajax({
			url: url,
			type: 'POST',
			dataType: 'json',
			data: {id:id},
		})
		.done(function(data) {
			if (data.status == 1) {
				alert(data.info);
				 location.reload();
			}else{
				alert(data.info);
			}
			
		})
		.fail(function() {
			alert('网络延迟!');
		});
		
	});

	</script>
</body>
</html>
